<!DOCTYPE html>
<html>
<head>
    <title>子串统计</title>
</head>
<body>
    请输入一个字符串：<input type="text" id="strInput"><br>
    请输入一个子串：<input type="text" id="subStrInput"><br>
    <button onclick="countSubStr()">提交</button><br>
    子串出现的次数为：<span id="result"></span>
    <script>
        function countSubStr() {
            var str = document.getElementById('strInput').value;
            var subStr = document.getElementById('subStrInput').value;
            var count = 0;
            for (var i = 0; i < str.length - subStr.length + 1; i++) {
                if (str.slice(i, i + subStr.length) === subStr) {
                    count++;
                }
            }
            document.getElementById('result').innerHTML = count;
        }
    </script>
</body>
</html>